package com.ruoyi.web.controller.book;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GiftRecords;
import com.ruoyi.system.service.IGiftRecordsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 礼金明细Controller
 * 
 * @author ruoyi
 * @date 2025-08-11
 */
@RestController
@RequestMapping("/system/records")
public class GiftRecordsController extends BaseController
{
    @Autowired
    private IGiftRecordsService giftRecordsService;

    /**
     * 查询礼金明细列表
     */
    @GetMapping("/list")
    public TableDataInfo list(GiftRecords giftRecords)
    {
        startPage();
        List<GiftRecords> list = giftRecordsService.selectGiftRecordsList(giftRecords);
        return getDataTable(list);
    }

    /**
     * 导出礼金明细列表
     */
    @Log(title = "礼金明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GiftRecords giftRecords)
    {
        List<GiftRecords> list = giftRecordsService.selectGiftRecordsList(giftRecords);
        ExcelUtil<GiftRecords> util = new ExcelUtil<GiftRecords>(GiftRecords.class);
        util.exportExcel(response, list, "礼金明细数据");
    }

    /**
     * 获取礼金明细详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(giftRecordsService.selectGiftRecordsById(id));
    }

    /**
     * 新增礼金明细
     */
    @Log(title = "礼金明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GiftRecords giftRecords)
    {
        return toAjax(giftRecordsService.insertGiftRecords(giftRecords));
    }

    /**
     * 修改礼金明细
     */
    @Log(title = "礼金明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GiftRecords giftRecords)
    {
        return toAjax(giftRecordsService.updateGiftRecords(giftRecords));
    }

    /**
     * 删除礼金明细
     */
    @Log(title = "礼金明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(giftRecordsService.deleteGiftRecordsByIds(ids));
    }
}
